# -*- coding: utf-8 -*-
"""
__mktime__ = '2019/4/14'
__author__ = 'Just'
__filename__ = 'mh_section'
"""
from sqlalchemy import Column, Integer, String, orm, ForeignKey
from app.model.base import BaseModel, db


class ComicSection(BaseModel):
    """漫画章节"""
    __tablename__ = 'comic_section'

    id = Column(Integer, primary_key=True, autoincrement=True)
    sid = Column(Integer, nullable=False, comment='章节id')
    title = Column(String(32), comment='章节标题')
    copyright = Column(Integer, comment='特殊标记 默认 1:正常  0:有版权纠纷')
    cid = Column(Integer, ForeignKey('comic.cid'), nullable=False, comment='漫画id')

    # 一对多 一章节有多组图片
    sections = db.relationship('ComicImage', backref='comic_image', lazy='dynamic')

    @orm.reconstructor
    def __init__(self):
        # 序列化列表
        self.fields = ['id', 'cid', 'sid', 'title', 'copyright']
